<html>
<meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
<body>
<?php
if(isset($_POST["bd"]) && isset($_POST["kt"]))
{
	$bd = $_POST["bd"];
	$kt = $_POST["kt"];
	$tong = 0;
	$tich = 1;
	$le = 0;
	$chan=0;
	$i = $bd;
	while($i <= $kt)
	{
		$tong = $tong + $i;
		$tich = $tich * $i;
		if($i % 2 == 0)
		{
			$chan ++;
		}
		else
		{
			++ 	$le;
		}
		$i ++;
	}
}
?>
<form id="form1"name="form1"method="post"action="TinhToanTrenDaySo_ver2.php">
	<table align="center">
		<tr>
			<td colspan="3"><span>TÍNH TOÁN TRÊN DÃY SỐ</span></td>
		
		</tr>
		
		
		<tr>
			<td><span>giới hạn của dãy số</span></td>
			<td><span>bắt đầu:</span><label><input id="bd"name="bd"type="text"value="<?php
				if(isset($_POST["bd"]))
				{
					echo $_POST["bd"];
				}
			?>"/></label></td>
			<td><span>kết thúc:</span><label><input id="kt"name="kt"type="text"value="<?php
				if(isset($_POST["kt"]))
				{
					echo $_POST["kt"];
				}
			?>"/></label></td>
		</tr>
		<tr>
			<td colspan="3" align="left"><span>kết quả: </span></td>
			
		</tr>
		<tr>
			<td><span>tổng :</span></td>
			<td colspan="2"><label><input id="tong"name="tong"type="text"value="<?php
			if(isset($_POST["tong"]))
			{
				echo $tong;
			}
			?>"/></label></td>
		</tr>
		<tr>
			<td><span>tích :</span></td>
			<td colspan="2"><label><input id="tich"name="tich"type="text"value="<?php
			if(isset($_POST["tich"]))
			{
				echo $tich;
			}
			?>"/></label></td>
		</tr>
		<tr>
			<td><span>tống số chẵn :</span></td>
			<td colspan="2"><label><input id="chan"name="chan"type="text"value="<?php
			if(isset($_POST["chan"]))
			{
				echo $chan;
			}
			?>"/></label></td>
		</tr>
		<tr>
			<td><span>tổng số lẻ :</span></td>
			<td colspan="2"><label><input id="le"name="le"type="text"value="<?php
			if(isset($_POST["le"]))
			{
				echo $le;
			}
			?>"/></label></td>
		</tr>
		<tr>
			<td colspan="3"><label><input id="submit"name="submit"type="submit"value="tính"/></label></td>
		</tr>
	
	</table>

</form>
</body>
</html>